<?php
/**
 * Created by PhpStorm.
 * User: wincol
 * Date: 2018/3/23
 * Time: 21:11
 */

namespace App\Task;


use Hhxsv5\LaravelS\Swoole\Task\Task;
use Illuminate\Support\Facades\Mail;

class SendMailTask extends Task
{
    public $user_address;
    public $view;
    public $param;
    public $data;

    /**
     * SendMailTask constructor.
     * @param $user_address
     * @param $data ['view','param']
     */
    public function __construct($user_address, $data)
    {
        $this->data = $data;
        $this->user_address = $user_address;
        $this->view = $data['view'];
        $this->param = $data['param'];
    }
    public function handle()
    {
        file_put_contents(storage_path('logs').DIRECTORY_SEPARATOR.'debug.log',
            json_encode($this->data),FILE_APPEND);
        Mail::to($this->user_address)->send(new $this->view($this->param));
    }
    public function finish(){

    }
}